/**
 * CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

package com.cmcc.zysoft.infocollection.service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.cmcc.zysoft.infocollection.dao.MessagePcDao;
import com.cmcc.zysoft.infocollection.model.Message;
import com.starit.common.dao.hibernate.HibernateBaseDao;
import com.starit.common.dao.service.BaseServiceImpl;

/**
 * @author 袁凤建
 * <br />邮箱: yuan.fengjian@ustcinfo.com
 * <br />描述: MessagePcService.java
 * <br />版本: 1.0.0
 * <br />日期: 2013-8-30 下午1:11:24
 * <br />CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

@Service
public class MessagePcService extends BaseServiceImpl<Message, String> {

	@Resource
	private MessagePcDao messagePcDao;
	
	@Override
	public HibernateBaseDao<Message, String> getHibernateBaseDao() {
		return this.messagePcDao;
	}
	
	/**
	 * 保存资源审核结果.
	 * @param resourceId 资源ID
	 * @param resourceName 资源名称
	 * @param approveResult 审核结果(-1-不通过,1-通过)
	 * @param approveMsg 审核意见
	 * @param userId 用户ID/审核人ID
	 * @param mobile 用户手机号/审核人手机号
	 */
	@Transactional
	public void addMessage(String resourceId, String resourceName, String approveResult, String approveMsg, String userId, String mobile) {
		Message message = new Message();
		message.setMessageTitle("【" + resourceName + "】审核结果");
		message.setMessageContent(approveMsg);
		message.setMessageReadFlag("0");
		message.setMessageType("1");
		message.setMessageKey(resourceId);
		message.setMobile(mobile);
		message.setAddMan(userId);
		message.setAddDate(new Date());
		this.messagePcDao.save(message);
	}
	
	/**
	 * 根据资源ID获取资源审核记录.
	 * @param resourceId 资源ID
	 * @return List<Map<String, Object>>
	 */
	public List<Map<String, Object>> getMessageList(String resourceId){
		return this.messagePcDao.getMessageList(resourceId);
	}
}